<?php

namespace app\admin\validate;

use think\Validate;

class Communitybaseinfo extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'school_id' => 'require|number',
        'location_id' => 'require|number',
        'location_address' => 'require|max:255',
        'description' => 'max:1000',
        'admin_id' => 'require|number',
        'contact_phone' => 'require|max:20',
        'status' => 'in:0,1',
        'weigh' => 'number',
    ];
    
    /**
     * 提示消息
     */
    protected $message = [
        'school_id.require' => '学校必须选择',
        'school_id.number' => '学校ID必须是数字',
        'location_id.require' => '教学点必须选择',
        'location_id.number' => '教学点ID必须是数字',
        'location_address.require' => '定位地址不能为空',
        'location_address.max' => '定位地址不能超过255个字符',
        'description.max' => '描述不能超过1000个字符',
        'admin_id.require' => '社区管理员必须选择',
        'admin_id.number' => '社区管理员ID必须是数字',
        'contact_phone.require' => '联系电话不能为空',
        'contact_phone.max' => '联系电话不能超过20个字符',
        'status.in' => '状态只能是0或1',
        'weigh.number' => '权重必须是数字',
    ];
    
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['school_id', 'location_id', 'location_address', 'admin_id', 'contact_phone', 'status', 'weigh'],
        'edit' => ['school_id', 'location_id', 'location_address', 'admin_id', 'contact_phone', 'status', 'weigh'],
    ];
}